package com.elong.businesstravel.modules.home.adapter;

import java.util.List;

import com.elong.businesstravel.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class SimpleListDialogAdapter extends BaseAdapter {

	private List<String> mStrings;
	private Context mContext;
	private String mSelect;

	public SimpleListDialogAdapter(Context context, List<String> strings,
			String select) {
		mContext = context;
		mStrings = strings;
		mSelect = select;
	}

	@Override
	public int getCount() {
		return mStrings.size();
	}

	@Override
	public Object getItem(int position) {
		return mStrings.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		if (null == convertView) {
			convertView = LayoutInflater.from(mContext).inflate(
					R.layout.view_simple_list_dialog_item, null);
		}

		TextView itemTextView = (TextView) convertView
				.findViewById(R.id.itemTextView);
		itemTextView.setText(mStrings.get(position));

//		ViewGroup simpleLayout = (ViewGroup) convertView
//				.findViewById(R.id.simpleLayout);
		if (mSelect.equals(mStrings.get(position))) {
			itemTextView.setSelected(true);
		} else {
			itemTextView.setSelected(false);
		}

		return convertView;
	}

}
